Raty={
	init:function(setting) {
		var oriSetting = {
			noRatedMsg:'还没有人评价过',
			path:SKYLINE_DOMAIN+'/img/star/',
			hintList:['很不好玩','不好玩','一般','好玩','很好玩'],
			readOnly : false,
			starOff : 'star-off.png',
			starOn : 'star-on.png',
			click : function(score) {
				Raty.vote(setting.targetId, score, setting.targetType, setting.targetObj, setting.numId, setting.start);
			}
		};
		if(setting.isBig){$.extend(oriSetting,{size:24,starOff:'star-off-big.png',starOn:'star-on-big.png'});}
		$.extend(oriSetting,setting);
		$(setting.targetObj).raty(oriSetting);
	},

	vote:function(id, score, objType, targetObj, numId, oldScore) {
		var _url = SKYLINE_DOMAIN+"/vote.html";
		var _reqUrl;
		if (objType == 'ATTRACTION') {
			_reqUrl = SKYLINE_DOMAIN+"/attraction/view/"+id+".html";
		} else if (objType == 'FEATURE') {
			_reqUrl = SKYLINE_DOMAIN+"/attraction/feature/"+id+".html";
	    } else
			return;
		var _data="id="+id+"&star="+score+"&type="+objType;
		doAjax(_url,_data, function(data){
			if(data.logined) {
				if(data.success) {
					$(targetObj).raty('start',data.star);
					$(targetObj).raty('readOnly',true);
					$("#"+numId).html(data.votes);
				} else {
					alert(data.errmsg);
					$(targetObj).raty('start',oldScore);
					if(data.voted) $(targetObj).raty('readOnly',true);
				}
			} else {
				alert(data.errmsg);
				window.location = SKYLINE_DOMAIN+'/login.html?requestFrom='+_reqUrl;
			}
		});
	}
};
